let socket
//  Websoket连接成功事件
const websocketonopen = (res) => {
  console.log('WebSocket连接成功', res)
}
// Websoket接收消息事件
const websocketonmessage = (res) => {
  console.log('接收消息', res)
}
// Websoket连接错误事件
const websocketonerror = (res) => {
  console.log('连接错误', res)
}
// Websoket断开事件
const websocketclose = (res) => {
  console.log('断开连接', res)
}
onMounted(() => {
  const wsurl =
        import.meta.env.VITE_SOCKET_URL
  socket = new WebSocket(wsurl)
  socket.onopen = websocketonopen
  socket.onmessage = websocketonmessage
  socket.onerror = websocketonerror
  socket.onclose = websocketclose
})
onBeforeUnmount(() => {
  // 关闭连接
  socket.close()
  // 销毁 websocket 实例对象
  socket = null
})
// 筛选器：提交
function handleFilterSubmit() {
// 发送事件
  socket.send(JSON.stringify({ deviceSN: queryParams.value.input }))
}

